<template>
  <el-dialog :visible.sync="value" :before-close="cancel">
    <template slot="title">
      有效会员配置
    </template>
    <el-form :model="form" :rules="refRule" ref="refForm" :label-width="formLabelWidth">
      <!--<el-form-item label="返水承担比例(%)" prop="rebate">-->
        <!--<el-col :span="8">-->
          <!--<el-input v-model.number="form.rebate">-->
            <!--<template slot="append">%</template>-->
          <!--</el-input>-->
        <!--</el-col>-->
        <!--<el-col :span="24">-->
          <!--<el-tip>给予代理线下玩家返水，由代理商承担的比例，填写0则代理不承担，建议 100%</el-tip>-->
        <!--</el-col>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="返水承担上限" prop="rebateLimit">-->
        <!--<el-col :span="8">-->
          <!--<el-input v-model.number="form.rebateLimit">-->
            <!--<template slot="append">元</template>-->
          <!--</el-input>-->
        <!--</el-col>-->
        <!--<el-col :span="24">-->
          <!--<el-tip>每次结算时，返水代理商的承担上限，填写0为不设置上限</el-tip>-->
        <!--</el-col>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="红利承担比例(%)" prop="activity">-->
        <!--<el-col :span="8">-->
          <!--<el-input v-model.number="form.activity">-->
            <!--<template slot="append">%</template>-->
          <!--</el-input>-->
        <!--</el-col>-->
        <!--<el-col :span="24">-->
          <!--<el-tip>线下玩家获取优惠红利时，代理商承担的比例，填写0则代理不承担，建议100%</el-tip>-->
        <!--</el-col>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="红利承担上限" prop="activityLimit">-->
        <!--<el-col :span="8">-->
          <!--<el-input v-model.number="form.activityLimit">-->
            <!--<template slot="append">元</template>-->
          <!--</el-input>-->
        <!--</el-col>-->
        <!--<el-col :span="24">-->
          <!--<el-tip>每次结算时，优惠红利代理商的承担上限，填写0为不设置上限</el-tip>-->
        <!--</el-col>-->
      <!--</el-form-item>-->
      <el-form-item label="有效会员当月投注总额" prop="bet">
        <el-col :span="8">
          <el-input v-model.number="form.bet" @keyup.enter.native="doSave({action: 'saveForm', form: 'refForm'})">
            <template slot="append">元</template>
          </el-input>
        </el-col>
        <el-col :span="24">
          <el-tip>玩家当月总投注超过这个金额，在代理结算时才记为有效会员，默认为0</el-tip>
        </el-col>
      </el-form-item>
      <el-form-item label="有效会员当月投注注单数" prop="betCount">
        <el-col :span="8">
          <el-input v-model.number="form.betCount" @keyup.enter.native="doSave({action: 'saveForm', form: 'refForm'})">
            <template slot="append">单</template>
          </el-input>
        </el-col>
        <el-col :span="24">
          <el-tip>玩家当月总投注超过这个注单数，在代理结算时才记为有效会员，默认为0</el-tip>
        </el-col>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="doSave({action: 'saveForm', form: 'refForm'})">确 定</el-button>
    </div>

     <el-tip>注：需要同时满足这2个条件，才计算为有效会员</el-tip>
  </el-dialog>
</template>

<script>

  import {form, factory} from '@/build'
  import {getSettlementApportion, editSettlementApportion} from '@/services/api/commission';
  import ElTip from "@/components/Tip/index";

  export default {
    name: "settlement-apportion-dialog",
    components: {ElTip},
    props: ['value', 'id'],
    mixins: [form, factory],
    data() {
      return {
        formLabelWidth: '180px',
        keywords: '',
        form: {},
        refRule: {
          activity: factory.getRule('percent'),
          activityLimit: factory.getRule('money'),
          rebate: factory.getRule('percent'),
          rebateLimit: factory.getRule('money'),
          bet: factory.getRule('money'),
          betCount: factory.getRule('times'),
        }
      }
    },

    mounted() {
      this.bindGet(getSettlementApportion, 'form', {
        sendingData: {id: this.id},
      })
      this.getAll()
      this.bindSave(editSettlementApportion, 'saveForm', 'form', {
        beforeSend: () => {
          this.form.id = this.id
          return this.form
        },
        afterSuccess: () => {
          this.cancel()
          this.$parent.getAll()
        }
      });
    },
    methods: {
      cancel() {
        this.$emit('input', false);
      },
    },

  }
</script>

<style lang="scss" scoped>

</style>
